#include "gtkclipboard.h"
#include "gtkcomboboxtext.h"
#include "gtkentry.h"
+#include "gtkstack.h"
#include "gtkexpander.h"
#include "gtkfilechooserprivate.h"
#include "gtkfilechooserdialog.h"
GtkWidget *browse_widgets_box;
GtkWidget *browse_widgets_hpaned;
GtkWidget *browse_header_box;
+ GtkWidget *browse_header_stack;
GtkWidget *browse_files_box;
GtkWidget *browse_files_tree_view;
GtkWidget *browse_files_popup_menu;
GtkWidget *extra_align;
GtkWidget *extra_widget;
- GtkWidget *location_button;
GtkWidget *location_entry_box;
GtkWidget *location_label;
GtkWidget *location_entry;
static void update_appearance (GtkFileChooserWidget *impl);
static void operation_mode_set (GtkFileChooserWidget *impl, OperationMode mode);
+static void location_mode_set (GtkFileChooserWidget *impl, LocationMode new_mode);
static void set_current_filter (GtkFileChooserWidget *impl,
GtkFileFilter *filter);
static void load_remove_timer (GtkFileChooserWidget *impl, LoadState new_load_state);
static void browse_files_center_selected_row (GtkFileChooserWidget *impl);
-static void location_button_toggled_cb (GtkToggleButton *toggle,
- GtkFileChooserWidget *impl);
static void location_switch_to_path_bar (GtkFileChooserWidget *impl);
static void stop_loading_and_clear_list_model (GtkFileChooserWidget *impl,
* in Nautilus, and do operation_mode_set (impl, OPERATION_MODE_SEARCH);
*/
+ location_mode_set (impl, LOCATION_MODE_PATH_BAR);
+
if (file_is_recent_uri (location))
operation_mode_set (impl, OPERATION_MODE_RECENT);
else
priv->location_entry = NULL;
}
- gtk_widget_hide (priv->browse_header_box);
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "pathbar");
}
/* Turns on the location entry. Can be called even if we are already in that
/* Done */
gtk_widget_show (priv->location_entry);
+
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "location");
+
gtk_widget_grab_focus (priv->location_entry);
}
-/* Sets a new location mode. set_buttons determines whether the toggle button
- * for the mode will also be changed.
+/* Sets a new location mode.
*/
static void
location_mode_set (GtkFileChooserWidget *impl,
- LocationMode new_mode,
- gboolean set_button)
+ LocationMode new_mode)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
{
GtkWindow *toplevel;
GtkWidget *current_focus;
- gboolean button_active;
gboolean switch_to_file_list;
switch (new_mode)
{
case LOCATION_MODE_PATH_BAR:
- button_active = FALSE;
/* The location_entry will disappear when we switch to path bar mode. So,
* we'll focus the file list in that case, to avoid having a window with
break;
case LOCATION_MODE_FILENAME_ENTRY:
- button_active = TRUE;
location_switch_to_filename_entry (impl);
break;
g_assert_not_reached ();
return;
}
-
- if (set_button)
- {
- g_signal_handlers_block_by_func (priv->location_button,
- G_CALLBACK (location_button_toggled_cb), impl);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->location_button), button_active);
-
- g_signal_handlers_unblock_by_func (priv->location_button,
- G_CALLBACK (location_button_toggled_cb), impl);
- }
}
priv->location_mode = new_mode;
}
+/* Callback used when the places sidebar needs us to enter a location */
+static void
+places_sidebar_show_enter_location_cb (GtkPlacesSidebar *sidebar,
+ GtkFileChooserWidget *impl)
+{
+ location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY);
+}
+
static void
location_toggle_popup_handler (GtkFileChooserWidget *impl)
{
*/
if (priv->location_mode == LOCATION_MODE_PATH_BAR)
{
- location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY, TRUE);
+ location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY);
}
else if (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY)
{
if (gtk_widget_has_focus (priv->location_entry))
{
- location_mode_set (impl, LOCATION_MODE_PATH_BAR, TRUE);
+ location_mode_set (impl, LOCATION_MODE_PATH_BAR);
}
else
{
}
}
-/* Callback used when one of the location mode buttons is toggled */
-static void
-location_button_toggled_cb (GtkToggleButton *toggle,
- GtkFileChooserWidget *impl)
-{
- GtkFileChooserWidgetPrivate *priv = impl->priv;
- gboolean is_active;
- LocationMode new_mode;
-
- is_active = gtk_toggle_button_get_active (toggle);
-
- if (is_active)
- {
- g_assert (priv->location_mode == LOCATION_MODE_PATH_BAR);
- new_mode = LOCATION_MODE_FILENAME_ENTRY;
- }
- else
- {
- g_assert (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY);
- new_mode = LOCATION_MODE_PATH_BAR;
- }
-
- location_mode_set (impl, new_mode, FALSE);
-}
-
typedef enum {
PATH_BAR_FOLDER_PATH,
PATH_BAR_SELECT_A_FOLDER,
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
- gtk_widget_show (priv->location_button);
- location_mode_set (impl, priv->location_mode, TRUE);
+ location_mode_set (impl, priv->location_mode);
- if (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY)
- gtk_widget_show (priv->browse_header_box);
+ gtk_widget_show (priv->browse_header_box);
}
}
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
- gtk_widget_hide (priv->location_button);
gtk_widget_hide (priv->browse_header_box);
}
{
const char *text;
- gtk_widget_hide (priv->location_button);
save_widgets_create (impl);
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
else if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
- gtk_widget_show (priv->location_button);
save_widgets_destroy (impl);
- location_mode_set (impl, priv->location_mode, TRUE);
+ location_mode_set (impl, priv->location_mode);
}
if (priv->location_entry)
settings_load (GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
- LocationMode location_mode;
gboolean show_hidden;
gboolean show_size_column;
gboolean sort_directories_first;
settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
- location_mode = g_settings_get_enum (settings, SETTINGS_KEY_LOCATION_MODE);
show_hidden = g_settings_get_boolean (settings, SETTINGS_KEY_SHOW_HIDDEN);
show_size_column = g_settings_get_boolean (settings, SETTINGS_KEY_SHOW_SIZE_COLUMN);
sort_column = g_settings_get_enum (settings, SETTINGS_KEY_SORT_COLUMN);
startup_mode = g_settings_get_enum (settings, SETTINGS_KEY_STARTUP_MODE);
sort_directories_first = g_settings_get_boolean (settings, SETTINGS_KEY_SORT_DIRECTORIES_FIRST);
- location_mode_set (impl, location_mode, TRUE);
-
gtk_file_chooser_set_show_hidden (GTK_FILE_CHOOSER (impl), show_hidden);
priv->show_size_column = show_size_column;
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
- gtk_widget_hide (priv->location_button);
gtk_widget_hide (priv->browse_header_box);
}
if (!path)
return;
- location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY, TRUE);
+ location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY);
location_set_user_text (impl, path);
}
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
/* A *lot* of widgets that we need to handle .... */
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_hpaned);
- gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_header_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_files_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, places_sidebar);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_files_tree_view);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_header_box);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_header_stack);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_new_folder_button);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_path_bar_hbox);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_path_bar_size_group);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, filter_combo);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, preview_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, extra_align);
- gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, location_button);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, location_entry_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, location_label);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, list_name_column);
gtk_widget_class_bind_template_callback (widget_class, renderer_editing_canceled_cb);
gtk_widget_class_bind_template_callback (widget_class, renderer_edited_cb);
gtk_widget_class_bind_template_callback (widget_class, filter_combo_changed);
- gtk_widget_class_bind_template_callback (widget_class, location_button_toggled_cb);
gtk_widget_class_bind_template_callback (widget_class, new_folder_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, path_bar_clicked);
gtk_widget_class_bind_template_callback (widget_class, places_sidebar_open_location_cb);
gtk_widget_class_bind_template_callback (widget_class, places_sidebar_show_error_message_cb);
+ gtk_widget_class_bind_template_callback (widget_class, places_sidebar_show_enter_location_cb);
}
static void
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">0</property>
- <child>
- <object class="GtkBox" id="browse_header_box">
- <property name="visible">False</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="border_width">10</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkBox" id="location_entry_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="location_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Location:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
<child>
<object class="GtkPaned" id="browse_widgets_hpaned">
<property name="visible">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">none</property>
<property name="local_only">True</property>
+ <property name="show_enter_location">True</property>
<signal name="open-location" handler="places_sidebar_open_location_cb" swapped="no"/>
<signal name="show-error-message" handler="places_sidebar_show_error_message_cb" swapped="no"/>
+ <signal name="show-enter-location" handler="places_sidebar_show_enter_location_cb" swapped="no"/>
</object>
<packing>
<property name="resize">False</property>
<property name="orientation">vertical</property>
<property name="spacing">0</property>
<child>
- <object class="GtkBox" id="browse_path_bar_hbox">
- <property name="visible">True</property>
+ <object class="GtkBox" id="browse_header_box">
+ <property name="visible">False</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="orientation">vertical</property>
<property name="border_width">6</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkToggleButton" id="location_button">
+ <object class="GtkStack" id="browse_header_stack">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Type a file name</property>
- <property name="image">location_button_image</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="location_button-atkobject">
- <property name="AtkObject::accessible-name" translatable="yes">Type a file name</property>
- </object>
- </child>
- <signal name="toggled" handler="location_button_toggled_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkPathBar" id="browse_path_bar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <signal name="path-clicked" handler="path_bar_clicked" after="yes" swapped="no"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkInfoBar" id="browse_select_a_folder_info_bar">
- <property name="app_paintable">True</property>
- <property name="can_focus">False</property>
- <child internal-child="content_area">
- <object class="GtkBox" id="infobar-content_area1">
+ <property name="transition-type">crossfade</property>
+ <property name="transition-duration">200</property>
+ <child>
+ <object class="GtkBox" id="browse_path_bar_hbox">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">8</property>
- <property name="spacing">16</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkImage" id="browse_select_a_folder_icon">
+ <object class="GtkPathBar" id="browse_path_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon_name">folder</property>
- <property name="icon_size">1</property>
+ <signal name="path-clicked" handler="path_bar_clicked" after="yes" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkInfoBar" id="browse_select_a_folder_info_bar">
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <child internal-child="content_area">
+ <object class="GtkBox" id="infobar-content_area1">
+ <property name="can_focus">False</property>
+ <property name="border_width">8</property>
+ <property name="spacing">16</property>
+ <child>
+ <object class="GtkImage" id="browse_select_a_folder_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">folder</property>
+ <property name="icon_size">1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="browse_select_a_folder_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">message</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="infobar-action_area1">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="browse_special_mode_icon">
+ <property name="can_focus">False</property>
+ <property name="icon_name">image-missing</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="browse_select_a_folder_label">
- <property name="visible">True</property>
+ <object class="GtkLabel" id="browse_special_mode_label">
<property name="can_focus">False</property>
- <property name="label">message</property>
+ <property name="label">special</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="browse_new_folder_button">
+ <property name="label" translatable="yes">Create Fo_lder</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="new_folder_button_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">5</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="name">pathbar</property>
+ </packing>
</child>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="infobar-action_area1">
+ <child>
+ <object class="GtkBox" id="location_entry_box">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <property name="layout_style">end</property>
+ <property name="no-show-all">True</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="location_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Location:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
+ <packing>
+ <property name="name">location</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkImage" id="browse_special_mode_icon">
- <property name="can_focus">False</property>
- <property name="icon_name">image-missing</property>
- </object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="browse_special_mode_label">
- <property name="can_focus">False</property>
- <property name="label">special</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="browse_new_folder_button">
- <property name="label" translatable="yes">Create Fo_lder</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="new_folder_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">5</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSizeGroup" id="browse_path_bar_size_group">
<property name="mode">vertical</property>
<widgets>
- <widget name="location_button"/>
<widget name="browse_path_bar"/>
<widget name="browse_select_a_folder_info_bar"/>
<widget name="browse_special_mode_icon"/>